//
//  SubjectAppView.m
//  LimitFree
//
//  Created by LZXuan on 15-6-9.
//  Copyright (c) 2015年 轩哥. All rights reserved.
//

#import "SubjectAppView.h"
#import "UIImageView+WebCache.h"

@interface SubjectAppView()
@property (nonatomic,weak) id target;
@property (nonatomic,assign) SEL action;
@end

@implementation SubjectAppView
- (void)awakeFromNib {
    //xib 初始化的时候会调用
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.cornerRadius = 5;
}

- (void)addTarget:(id)target action:(SEL)action {
    self.target = target;
    self.action = action;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if ([self.target respondsToSelector:self.action]) {
        [self.target performSelector:self.action withObject:self];
    }
}
#pragma clang diagnostic pop

- (void)showDataWithAppModel:(AppModel *)model {
    //先保存
    self.model = model;
    //填充内容
    self.nameLabel.text = model.name;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.iconUrl] placeholderImage:[UIImage imageNamed: @"topic_Header"]];
    self.downloadLabel.text = model.downloads;
    self.commentLabel.text = model.comment.stringValue;
    [self.starView setStarLevel:model.starOverall.doubleValue];
}

@end









